package com.ruoyi.jiajia.controller;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.JiajiaWorkerJiedan;
import com.ruoyi.system.service.IJiajiaWorkerJiedanService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 接单状态Controller
 * 
 * @author knd
 * @date 2021-10-19
 */
@Controller
@RequestMapping("/jiajia/jiajiajiedan")
public class JiajiaWorkerJiedanController extends BaseController
{
    private String prefix = "jiajia/jiajiajiedan";

    @Autowired
    private IJiajiaWorkerJiedanService jiajiaWorkerJiedanService;

    @RequiresPermissions("jiajia:jiajiajiedan:view")
    @GetMapping()
    public String jiajiajiedan()
    {
        return prefix + "/jiajiajiedan";
    }

    /**
     * 查询接单状态列表
     */
    @RequiresPermissions("jiajia:jiajiajiedan:list")
    @PostMapping("/list")
    @ResponseBody
    @DataScope(deptAlias="d")
    public TableDataInfo list(JiajiaWorkerJiedan jiajiaWorkerJiedan)
    {
        startPage();
        List<JiajiaWorkerJiedan> list = jiajiaWorkerJiedanService.selectJiajiaWorkerJiedanList(jiajiaWorkerJiedan);
        return getDataTable(list);
    }

    /**
     * 导出接单状态列表
     */
    @RequiresPermissions("jiajia:jiajiajiedan:export")
    @Log(title = "接单状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaWorkerJiedan jiajiaWorkerJiedan)
    {
        List<JiajiaWorkerJiedan> list = jiajiaWorkerJiedanService.selectJiajiaWorkerJiedanList(jiajiaWorkerJiedan);
        ExcelUtil<JiajiaWorkerJiedan> util = new ExcelUtil<JiajiaWorkerJiedan>(JiajiaWorkerJiedan.class);
        return util.exportExcel(list, "接单状态数据");
    }

    /**
     * 新增接单状态
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存接单状态
     */
    @RequiresPermissions("jiajia:jiajiajiedan:add")
    @Log(title = "接单状态", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaWorkerJiedan jiajiaWorkerJiedan)
    {
        return toAjax(jiajiaWorkerJiedanService.insertJiajiaWorkerJiedan(jiajiaWorkerJiedan));
    }

    /**
     * 修改接单状态
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaWorkerJiedan jiajiaWorkerJiedan = jiajiaWorkerJiedanService.selectJiajiaWorkerJiedanById(id);
        mmap.put("jiajiaWorkerJiedan", jiajiaWorkerJiedan);
        return prefix + "/edit";
    }

    /**
     * 修改保存接单状态
     */
    @RequiresPermissions("jiajia:jiajiajiedan:edit")
    @Log(title = "接单状态", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaWorkerJiedan jiajiaWorkerJiedan)
    {
        return toAjax(jiajiaWorkerJiedanService.updateJiajiaWorkerJiedan(jiajiaWorkerJiedan));
    }

    /**
     * 删除接单状态
     */
    @RequiresPermissions("jiajia:jiajiajiedan:remove")
    @Log(title = "接单状态", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaWorkerJiedanService.deleteJiajiaWorkerJiedanByIds(ids));
    }
}
